package com.cykj.handler;

import com.cykj.entity.UserEntity;
import com.cykj.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserManagHandler {
    @Autowired
    private UserService userService;
    @RequestMapping("/GetUser")
    public Map<String,Object> GetUser(){
        List<UserEntity> list = userService.find();
        Map<String,Object> map = new HashMap<>();
        map.put("data",list);
        return map;
    }

    @RequestMapping("/deletUser")
    public int deletUser(HttpServletRequest req){
        String id = req.getParameter("id");
        int i = userService.deleteUser(Integer.parseInt(id));
        return i;

    }
}
